package nc.impl.hrmm;

import java.util.List;
import java.util.Map;

import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.itf.hrmm.ICadreInfoManageMaintain;
import nc.jdbc.framework.SQLParameter;
import nc.jdbc.framework.processor.BeanProcessor;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.jdbc.framework.processor.MapProcessor;
import nc.vo.mm.ldpsninfo.LdClassInfoVO;

public class CadreInfoManageMaintainImpl implements ICadreInfoManageMaintain{
	
	@Override
	public Map<String, Object> queryHrorg(String name) throws DAOException {
		StringBuffer sb = new StringBuffer();
		sb.append("select code,name,pk_hrorg,pk_group from org_hrorg where name like '%" + name + "%' and dr = 0");
		Map<String, Object> hrorg = (Map<String, Object>) new BaseDAO().executeQuery(sb.toString(), new MapProcessor());
		return hrorg;
	}
	
	@Override
	public List<Map<String, Object>> queryHrorg() throws DAOException {
		StringBuffer sb = new StringBuffer();
		sb.append("select code,enablestate,name,pk_hrorg from org_hrorg where dr = 0");
		List<Map<String, Object>> hrorgs = (List<Map<String, Object>>) new BaseDAO().executeQuery(sb.toString(), new MapListProcessor());
		return hrorgs;
	}
	
	@Override
	public LdClassInfoVO queryLdclassinfoByPk(String pk) throws DAOException {
		StringBuffer sb = new StringBuffer();
		sb.append("select * from hrmm_ldclassinfo where ldclass_name6 = '");
		sb.append(pk);
		sb.append("' ");
		LdClassInfoVO ldClass = (LdClassInfoVO) new BaseDAO().executeQuery(sb.toString(), new BeanProcessor(LdClassInfoVO.class));
		return ldClass;
	}  
	
	@Override
	public void updateLdclassinfoByPk(Map<String, Object> hrorg) throws DAOException {
		StringBuffer sb = new StringBuffer();
		sb.append("update hrmm_ldclassinfo set enablestate = ?,ldclass_code = ?,ldclass_name = ? where ldclass_name6 = ? ");
		SQLParameter parameter = new SQLParameter();
		parameter.addParam(hrorg.get("enablestate") == null?Integer.valueOf(2):hrorg.get("enablestate"));
		parameter.addParam(hrorg.get("code") == null?"":hrorg.get("code"));
		parameter.addParam(hrorg.get("name")==null?"":hrorg.get("name"));
		parameter.addParam(hrorg.get("pk_hrorg")==null?"":hrorg.get("pk_hrorg"));
		new BaseDAO().executeUpdate(sb.toString(), parameter);
	}

}
